<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Spec::Rails::Example::ControllerExampleGroup</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Spec::Rails::Example::ControllerExampleGroup</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group_rb.html">
                vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="FunctionalExampleGroup.html">
                FunctionalExampleGroup
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Controller Examples live in $RAILS_ROOT/spec/controllers/.
</p>
<p>
Controller Examples use <a
href="ControllerExampleGroup.html">Spec::Rails::Example::ControllerExampleGroup</a>,
which supports running specs for Controllers in two modes, which represent
the tension between the more granular testing common in TDD and the more
high level testing built into rails. BDD sits somewhere in between: we want
to a balance between specs that are close enough to the code to enable
quick fault isolation and far enough away from the code to enable
refactoring with minimal changes to the existing specs.
</p>
<h2>Isolation mode (default)</h2>
<p>
No dependencies on views because none are ever rendered. The benefit of
this mode is that can spec the controller completely independent of the
view, allowing that responsibility to be handled later, or by somebody
else. Combined w/ separate view specs, this also provides better fault
isolation.
</p>
<h2>Integration mode</h2>
<p>
To run in this mode, include the <tt><a
href="ControllerExampleGroup.html#M000055">integrate_views</a></tt>
declaration in your controller context:
</p>
<pre>
  describe ThingController do
    integrate_views
    ...
</pre>
<p>
In this mode, controller specs are run in the same way that rails
functional tests run - one set of tests for both the controllers and the
views. The benefit of this approach is that you get wider coverage from
each spec. Experienced rails developers may find this an easier approach to
begin with, however we encourage you to explore using the isolation mode
and revel in its benefits.
</p>
<h2>Expecting Errors</h2>
<p>
Rspec on <a href="../../Rails.html">Rails</a> will raise errors that occur
in controller actions. In contrast, <a href="../../Rails.html">Rails</a>
will swallow errors that are raised in controller actions and return an
error code in the header. If you wish to override Rspec and have
Rail&#8216;s default behaviour,tell the controller to use rails error
handling &#8230;
</p>
<pre>
  before(:each) do
    controller.use_rails_error_handling!
  end
</pre>
<p>
When using Rail&#8216;s error handling, you can expect error codes in
headers &#8230;
</p>
<pre>
  it &quot;should return an error in the header&quot; do
    response.should be_error
  end

  it &quot;should return a 501&quot; do
    response.response_code.should == 501
  end

  it &quot;should return a 501&quot; do
    response.code.should == &quot;501&quot;
  end
</pre>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000059">_assigns_hash_proxy</a>&nbsp;&nbsp;
      <a href="#M000056">controller_name</a>&nbsp;&nbsp;
      <a href="#M000055">integrate_views</a>&nbsp;&nbsp;
      <a href="#M000058">params_from</a>&nbsp;&nbsp;
      <a href="#M000057">route_for</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name">ControllerInstanceMethods</span>
      </div>
    </div>

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">controller</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">request</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">response</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000056" class="method-detail">
        <a name="M000056"></a>

        <div class="method-heading">
          <a href="#M000056" class="method-signature">
          <span class="method-name">controller_name</span><span class="method-args">(name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
You MUST provide a <a
href="ControllerExampleGroup.html#M000056">controller_name</a> within the
context of your controller specs:
</p>
<pre>
  describe &quot;ThingController&quot; do
    controller_name :thing
    ...
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000056-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb, line 95</span>
95:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">controller_name</span>(<span class="ruby-identifier">name</span>)
96:             <span class="ruby-ivar">@controller_class_name</span> = <span class="ruby-node">&quot;#{name}_controller&quot;</span>.<span class="ruby-identifier">camelize</span>
97:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000055" class="method-detail">
        <a name="M000055"></a>

        <div class="method-heading">
          <a href="#M000055" class="method-signature">
          <span class="method-name">integrate_views</span><span class="method-args">(integrate_views = true)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Use this to instruct RSpec to render views in your controller examples
(Integration Mode).
</p>
<pre>
  describe ThingController do
    integrate_views
    ...
</pre>
<p>
See <a
href="ControllerExampleGroup.html">Spec::Rails::Example::ControllerExampleGroup</a>
for more information about Integration and Isolation modes.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000055-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb, line 75</span>
75:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">integrate_views</span>(<span class="ruby-identifier">integrate_views</span> = <span class="ruby-keyword kw">true</span>)
76:             <span class="ruby-ivar">@integrate_views</span> = <span class="ruby-identifier">integrate_views</span>
77:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000058" class="method-detail">
        <a name="M000058"></a>

        <div class="method-heading">
          <a href="#M000058" class="method-signature">
          <span class="method-name">params_from</span><span class="method-args">(method, path)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Uses ActionController::Routing::Routes to parse an incoming path so the
parameters it generates can be checked
</p>
<h2><a href="../Example.html">Example</a></h2>
<pre>
  params_from(:get, '/registrations/1;edit')
    =&gt; :controller =&gt; 'registrations', :action =&gt; 'edit', :id =&gt; 1
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000058-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb, line 155</span>
155:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params_from</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">path</span>)
156:           <span class="ruby-identifier">ensure_that_routes_are_loaded</span>
157:           <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Routing</span><span class="ruby-operator">::</span><span class="ruby-constant">Routes</span>.<span class="ruby-identifier">recognize_path</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">:method</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">method</span>)
158:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000057" class="method-detail">
        <a name="M000057"></a>

        <div class="method-heading">
          <a href="#M000057" class="method-signature">
          <span class="method-name">route_for</span><span class="method-args">(options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Uses ActionController::Routing::Routes to generate the correct route for a
given set of options.
</p>
<h2><a href="../Example.html">Example</a></h2>
<pre>
  route_for(:controller =&gt; 'registrations', :action =&gt; 'edit', :id =&gt; 1)
    =&gt; '/registrations/1;edit'
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000057-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb, line 145</span>
145:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">route_for</span>(<span class="ruby-identifier">options</span>)
146:           <span class="ruby-identifier">ensure_that_routes_are_loaded</span>
147:           <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Routing</span><span class="ruby-operator">::</span><span class="ruby-constant">Routes</span>.<span class="ruby-identifier">generate</span>(<span class="ruby-identifier">options</span>)
148:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M000059" class="method-detail">
        <a name="M000059"></a>

        <div class="method-heading">
          <a href="#M000059" class="method-signature">
          <span class="method-name">_assigns_hash_proxy</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000059-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb, line 161</span>
161:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_assigns_hash_proxy</span>
162:           <span class="ruby-ivar">@_assigns_hash_proxy</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">AssignsHashProxy</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">do</span>
163:             <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">template</span>
164:           <span class="ruby-keyword kw">end</span>
165:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>